package com.shensi.api.admin.client.customer;

import com.shensi.api.admin.client.fallback.customer.CardExcelImportClientFallBack;
import com.shensi.api.admin.domian.customer.dto.CardExcelImportDto;
import com.shensi.common.core.annotation.Excel;
import com.shensi.common.core.annotation.Log;
import com.shensi.common.core.constant.CloudConstant;
import com.shensi.common.core.domain.AjaxResult;
import com.shensi.common.core.domain.entity.SysUser;
import com.shensi.common.core.domain.model.LoginUser;
import com.shensi.common.core.enums.BusinessType;
import com.shensi.common.core.enums.ErrorCode;
import com.shensi.common.core.exception.CustomException;
import com.shensi.common.core.page.TableDataInfo;
import com.shensi.common.core.utils.SecurityUtils;
import com.shensi.common.core.utils.StringUtils;
import com.shensi.common.core.utils.poi.ExcelUtil;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 * @author: budian
 * @since: 2023/11/30
 */
@FeignClient(
        value = CloudConstant.ADMIN_SERVER,
        fallbackFactory = CardExcelImportClientFallBack.class)
@Component
public interface CardExcelImportClient {


    /**
     * 导入excel的客户信息
     *
     * @param id 客户信息的
     * @return 客户电子会员卡充值消费记录
     */
    @GetMapping(value = "/customer/cardImport/{id}")
    public AjaxResult selectCardExcelImportById(@PathVariable("id") Long id);

    /**
     * 查询导入excel信息
     *
     * @param cardExcelImport 条件
     * @return 客户电子会员卡充值消费记录
     */
    @GetMapping("/customer/cardImport/list")
    public TableDataInfo selectCardExcelImportList(@SpringQueryMap CardExcelImportDto cardExcelImport);

    /**
     * 下载模板
     */

    @GetMapping("/customer/cardImport/importTemplate")
    public AjaxResult importTemplate();


    /**
     * 导入list信息
     */
    @PostMapping("/customer/cardImport/importCardExcel")
    public AjaxResult importCardExcel(@RequestBody List<CardExcelImportDto> cardExcelImports);

    @PostMapping("/customer/cardImport/import")
    public AjaxResult importCardExcelData(@RequestParam("file") MultipartFile file) throws Exception ;

    @PostMapping("/customer/cardImport/importLabelUser/{labelId}")
    public AjaxResult importCardAndLabelUserExcelData(@RequestParam("file") MultipartFile file, @PathVariable("labelId") Long labelId) throws Exception;

    @GetMapping("/customer/cardImport/labelUserTemplate")
    public void downloadLabelUsertemplate(@SpringQueryMap HttpServletResponse response);

    @GetMapping("/customer/cardImport/template")
    public void downloadTemplate(@SpringQueryMap HttpServletResponse response);


    /**
     * 新增导入的信息
     *
     * @param cardExcelImport 新增的excel信息
     * @return 结果
     */
    @PostMapping("/customer/cardImport")
    public AjaxResult insertCardExcelImport(CardExcelImportDto cardExcelImport);

    /**
     * 修改导入的excel信息
     *
     * @param cardExcelImport 修改的导入客户信息
     * @return 结果
     */
    @PutMapping("/customer/cardImport")
    public AjaxResult updateCardExcelImport(CardExcelImportDto cardExcelImport);

    /**
     * 批量删除客户电子会员卡充值消费记录
     *
     * @param ids 需要删除的客户电子会员卡充值消费记录ID
     * @return 结果
     */
    @DeleteMapping("/customer/cardImport/{ids}")
    public AjaxResult deleteCardExcelImportByIds(Long[] ids);
}
